import request from '/@/utils/request';

/**
 * （不建议写成 request.post(xxx)，因为这样 post 时，无法 params 与 data 同时传参）
 */
const useLoginApi = {
    getCode: () => {
        return request({
            url: '/api/auth/code',
            method: 'get'
        });
    },
    signIn: (data: object) => {
        return request({
            url: '/api/auth/login',
            method: 'post',
            data
        });
    },
    signOut: (data: object) => {
        return request({
            url: '/user/signOut',
            method: 'post',
            data
        });
    },
    getUserInfo: () => {
        return request({
            url: '/api/system/user/getInfo',
            method: 'get'
        });
    },
    getRoutersByMenuType: (params: any) => {
        return request({
            url: '/api/system/menu/getRoutersByMenuType',
            method: 'get',
            params
        });
    },
    getRoutersByPrefix: (params: any) => {
        return request({
            url: '/api/system/menu/getRouters',
            method: 'get',
            params
        });
    }
};

export default useLoginApi;
